#include "convert.h"

char *formingName(char *, int, int, int);

void convert(char *directory)
{
    State state8(8), state12(12), state16(16);
    State state8_sample(8), state12_sample(12), state16_sample(16);
    int size = state8.getSize();
    char *name;

    complexd h[] = {
        complexd(1/sqrt(2), 0), complexd( 1/sqrt(2), 0),
        complexd(1/sqrt(2), 0), complexd(-1/sqrt(2), 0)
    };
    Conversion H(2,2,h);

    state8_sample.input("samples/state8");
    state12_sample.input("samples/state12");
    state16_sample.input("samples/state16");

    state8 = state8_sample;
    state8.doConversion(H,1);
    name = formingName(directory, 8, 1, size);
    state8.output(name);
    state8 = state8_sample;
    state8.doConversion(H,5);
    name = formingName(directory, 8, 5, size);
    state8.output(name);
    state8 = state8_sample;
    state8.doConversion(H,8);
    name = formingName(directory, 8, 8, size);
    state8.output(name);

    state12 = state12_sample;
    state12.doConversion(H,1);
    name = formingName(directory, 12, 1, size);
    state12.output(name);
    state12 = state12_sample;
    state12.doConversion(H,7);
    name = formingName(directory, 12, 7, size);
    state12.output(name);
    state12 = state12_sample;
    state12.doConversion(H,12);
    name = formingName(directory, 12, 12, size);
    state12.output(name);

    state16 = state16_sample;
    state16.doConversion(H,1);
    name = formingName(directory, 16, 1, size);
    state16.output(name);
    state16 = state16_sample;
    state16.doConversion(H,9);
    name = formingName(directory, 16, 9, size);
    state16.output(name);
    state16 = state16_sample;
    state16.doConversion(H,16);
    name = formingName(directory, 16, 16, size);
    state16.output(name);

}

char *formingName(char *directory, int length, int qbit, int size)
{
    char *name = new char [strlen(directory) + 20];
    sprintf(name, "%s/state_%d_%d_%d", directory, length, qbit, size);
    return name;
}
